#!/usr/bin/env python
# -*- coding: UTF-8 -*-
'''
@Project ：henan_sumo
@File ：config40.py
@IDE ：PyCharm
@Author ：xinyingjie
@Date ：2025/5/13 8:52
'''

from utils.tools import calculate_distance

USE_LIBSUMO = True
USE_GUI = False
SHOW_SIMU = True
KAFKA_HOST = '106.120.201.126:19359'
# LIDAR_RANGE = 40
# PINJIE_DIS = 55
HM_LIDAR_RANGE = 250
LIDAR_RANGE = 90
PINJIE_DIS = 50
KAFKA_E1_TOPIC = "e1_fusion_data_v3"
KAFKA_E1_OUT_1 = "e1_data_CJ-10-0"
KAFKA_E1_OUT_2 = "e1_data_CJ-10-0"
KAFKA_E1_IN_1 = "e1_data_JJ-10-0"
KAFKA_E1_IN_2 = "e1_data_JJ-10-0"
KAFKA_E1_LIST_1 = ['e1_data_CJ-10-01-0', 'e1_data_CJ-10-02-0', 'e1_data_JJ-10-01-0', 'e1_data_JJ-10-02-0']

KAFKA_E1_LIST = "fusion_E1_data"
KAFKA_E1_TOPIC_SIMU = "sumo_simu"
first_CJ = [11, 14]
first_JJ = [19, 20, 24]

RADAR_DATA_LIST_CJ = {
    11: {'sn': 11, 'lon': 116.4236011, 'lat': 39.77833934, 'Downstream': {'sn': 12}, 'Upstream': None, 'type': "jg",
         'topic': "e1_data_CJ-10-01", 'orgCode': "CJ-10-01", 'normal': True},
    12: {'sn': 12, 'lon': 116.4233678, 'lat': 39.77179096, 'Downstream': {'sn': 15}, 'Upstream': {'sn': 11},
         'type': "jg", 'HMDownstream': {'sn': 13}, 'topic': "e1_data_CJ-10-02", 'orgCode': "CJ-10-02", 'normal': True},
    13: {'sn': 13, 'lon': 116.42371, 'lat': 39.76847134, 'Downstream': None, 'Upstream': {'sn': 12}, 'type': "hm",
         'topic': "e1_data_CJ-10-03", 'orgCode': "CJ-10-03", 'normal': True},
    14: {'sn': 14, 'lon': 116.4247321, 'lat': 39.76152304, 'Downstream': {'sn': 15}, 'Upstream': None, 'type': "hm",
         'topic': "e1_data_CJ-10-04", 'orgCode': "CJ-10-04", 'normal': True},
    15: {'sn': 15, 'lon': 116.4261857, 'lat': 39.75540889, 'Downstream': {'sn': 16}, 'Upstream': {'sn': 12},
         'HMUpstream': {'sn': 14}, 'type': "jg", 'topic': "e1_data_CJ-10-05", 'orgCode': "CJ-10-05", 'normal': True},
    16: {'sn': 16, 'lon': 116.4285662, 'lat': 39.7464115, 'Downstream': {'sn': 18}, 'Upstream': {'sn': 15},
         'type': "jg", 'HMDownstream': {'sn': 17}, 'topic': "e1_data_CJ-10-06", 'orgCode': "CJ-10-06", 'normal': True},
    17: {'sn': 17, 'lon': 116.4290889, 'lat': 39.74394431, 'Downstream': None, 'Upstream': {'sn': 16}, 'type': "hm",
         'topic': "e1_data_CJ-10-07", 'orgCode': "CJ-10-07", 'normal': True},
    18: {'sn': 18, 'lon': 116.4306522, 'lat': 39.73931893, 'Downstream': None, 'Upstream': {'sn': 16}, 'type': "jg",
         'topic': "e1_data_CJ-10-08", 'orgCode': "CJ-10-08", 'normal': True},
}

RADAR_DATA_LIST_JJ = {
    19: {'sn': 19, 'lon': 116.4310726, 'lat': 39.73943829, 'Downstream': {'sn': 21}, 'Upstream': None, 'type': "jg",
         'topic': "e1_data_JJ-10-01", 'orgCode': "JJ-10-01", 'normal': True},
    20: {'sn': 20, 'lon': 116.4299701, 'lat': 39.7434342, 'Downstream': {'sn': 21}, 'Upstream': None, 'type': "hm",
         'topic': "e1_data_JJ-10-02", 'orgCode': "JJ-10-02", 'normal': True},
    21: {'sn': 21, 'lon': 116.4280638, 'lat': 39.75005531, 'Downstream': {'sn': 22}, 'Upstream': {'sn': 19},
         'HMUpstream': {'sn': 20}, 'type': "jg", 'topic': "e1_data_JJ-10-03", 'orgCode': "JJ-10-03", 'normal': True},
    22: {'sn': 22, 'lon': 116.4256975, 'lat': 39.75950848, 'Downstream': {'sn': 25}, 'HMDownstream': {'sn': 23},
         'Upstream': {'sn': 21}, 'type': "jg", 'topic': "e1_data_JJ-10-04", 'orgCode': "JJ-10-04", 'normal': True},
    23: {'sn': 23, 'lon': 116.4254769, 'lat': 39.7616087, 'Downstream': None, 'Upstream': {'sn': 22}, 'type': "hm",
         'topic': "e1_data_JJ-10-05", 'orgCode': "JJ-10-05", 'normal': True},
    24: {'sn': 24, 'lon': 116.4244934, 'lat': 39.7685285, 'Downstream': {'sn': 25}, 'Upstream': None, 'type': "hm",
         'topic': "e1_data_JJ-10-06", 'orgCode': "JJ-10-06", 'normal': True},
    25: {'sn': 25, 'lon': 116.4239826, 'lat': 39.77116232, 'Downstream': {'sn': 26}, 'Upstream': {'sn': 22},
         'HMUpstream': {'sn': 24}, 'type': "jg", 'topic': "e1_data_JJ-10-07", 'orgCode': "JJ-10-07", 'normal': True},
    26: {'sn': 26, 'lon': 116.4240484, 'lat': 39.77798255, 'Downstream': None, 'Upstream': {'sn': 25},
         'type': "jg", 'topic': "e1_data_JJ-10-08", 'orgCode': "JJ-10-08", 'normal': True},

}

# 全局中心点
GLOBAL_POLYGON_CENTER = [(4448.62, 202.30), (4408.84, 896.84),
                         (3674.53, 890.73), (3738.78, -76.12)]

MAX_SPEED = int(150 / 3.6)
MIN_SPEED = int(30 / 3.6)
CAR_DEFAULT_SPEED = 24
TRUCK_DEFAULT_SPEED = 20
SPECIAL_DEFAULT_SPEED = 18
# 经度逐渐减少
# 感知 第一种出现位置直接发车
# 第二个门架位置进行删车操作


if __name__ == '__main__':
    pass
    # print(list(RADAR_DATA_LIST.keys()))
    # for sn in list(RADAR_DATA_LIST.keys()):
    #     one = RADAR_DATA_LIST[sn]
    #     if one['Downstream']:
    #         print(one['lon'], one['lat'], RADAR_DATA_LIST[one['Downstream']['sn']]['lon'],
    #               RADAR_DATA_LIST[one['Downstream']['sn']]['lat'])
    #         print(calculate_distance(one['lon'], one['lat'], RADAR_DATA_LIST[one['Downstream']['sn']]['lon'],
    #                                  RADAR_DATA_LIST[one['Downstream']['sn']]['lat']))
    # result = {}
    # for RADAR_DATA in RADAR_DATA_LIST:
    #     # down_sn = {RADAR_DATA['sn'].split("_")[0] + str(int(RADAR_DATA['sn'].split("_")[1]) + 1)}
    #     RADAR_DATA['Downstream'] = {
    #         'sn': RADAR_DATA['sn'].split("_")[0] + "_" + str(int(RADAR_DATA['sn'].split("_")[1]) + 1)}
    #     RADAR_DATA['Upstream'] = {
    #         'sn': RADAR_DATA['sn'].split("_")[0] + "_" + str(int(RADAR_DATA['sn'].split("_")[1]) - 1)}
    #     RADAR_DATA['disDown'] = 1000
    #     RADAR_DATA['normal'] = True
    #     result[RADAR_DATA['sn']] = RADAR_DATA
    #
    # for k, v in result.items():
    #     if v['Downstream']['sn'] not in result.keys():
    #         result[k]['Downstream'] = None
    #     if v['Upstream']['sn'] not in result.keys():
    #         result[k]['Upstream'] = None
    # print(result)
